package com.koron.css2.serviceManage.mapper;

import com.koron.css2.common.dto.CascaderTreeDto;
import com.koron.css2.serviceManage.bean.KpiBean;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.koron.ebs.mybatis.EnvSource;

import java.util.List;

@EnvSource("_default")
public interface KpiMapper {
	
	/**
	 * 查询子主题(通过子主题分组)
	 * @param themeUnique
	 * @return
	 */
	List<CascaderTreeDto> selectSubTheme(String themeUnique);
	
	/**
	 * 通过子主题查询指标
	 * @param subTheme
	 * @return
	 */
	List<CascaderTreeDto> selectBySubTheme(String subTheme);
	
	/**
	 * 查询列表
	 * 
	 * @return
	 */
	List<KpiBean> selectKpiList();
	
	/**
	 * 
	 * @param kpiId
	 * @return
	 */
	KpiBean selectKpiById(@Param("kpiId") String kpiId);

	/**
	 * 添加pki
	 * 
	 * @param kpibean
	 * @return
	 */
	int insertKpi(KpiBean kpibean);
	
	/**
	 * 校验字段内容重复
	 */
	@Select("select count(*) from PUB_KPI where ${key} = #{val}")
	Integer check(@Param("key") String key, @Param("val") String val);
	
	/**
	 * 校验字段内容重复-排除当前记录
	 */
	@Select("select count(*) from PUB_KPI where ${key} = #{val} and id <> #{id}")
	Integer check2(@Param("key") String key, @Param("val") String val, @Param("id") String id);
	
	/**
	 * 修改kpi
	 * 
	 * @param tWaterCompany
	 * @return
	 */
	Integer updateKpi(KpiBean kpibean);

	public List<CascaderTreeDto> findDictionaryParamName(@Param("code") String code);

}
